// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()
const db = cloud.database()

// 云函数入口函数
// 添加一个数据到order
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  const goods = event.goods;
  let order = {
    openid:wxContext.OPENID,
    goods,
    status:0
  };
  const result = await db.collection("order").add({
    data:order,
  });

  return {
    code:200,
    msg:"添加购物车成功"
  }

  return {
    // event,
    // data:result,
    // openid: wxContext.OPENID,
    // appid: wxContext.APPID,
    // unionid: wxContext.UNIONID,
  }
}